<template>
  <BasicModal @register="register" :title="title" @ok="handleSubmit">
    <BasicForm @register="registerForm" />
    <!-- <p style="color: red; margin-left: 20px"> 提示：将会修改全部计划交付日期 </p> -->
  </BasicModal>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'ViewsWhRd02Rd02List',
  });
</script>
<script setup lang="ts">
  import { defineComponent, ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { BasicForm, FormSchema, useForm } from '/@/components/Form';
  import { rdJzrqSave,rdJzrqForm } from '/@/api/wms/rd/order/rdOrder';
  import { companyTreeData } from '/@/api/sys/company';
  const emit = defineEmits(['success', 'register', 'modifyjfdate']);
  const { showMessage } = useMessage();
  let record = ref<any>({});
    const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
    labelWidth: 80,
    schemas: [
      {
          label: '商品',
          field: 'basInv.invName',
          component: 'InputNumber',
          componentProps: {
            // maxlength: 255,
          },
          dynamicDisabled: true,
      },
      {
        label: '数量',
        field: 'fqty',
        component: 'InputNumber',
        componentProps: {
          // maxlength: 255,
        },
      },
      // {
      //   label: '关账公司',
      //   field: 'companyCode',
      //   fieldLabel: 'company.companyName',
      //   component: 'TreeSelect',
      //   componentProps: {
      //     api: companyTreeData,
      //     allowClear: true,
      //     // immediate: true,
      //     onChange: async (e) => {
      //       let res = await rdJzrqForm({companyCode:e});
      //       setFieldsValue({
      //         companyCode:e,
      //         jzdate:res.rdJzrq?.jzdate
      //       })
      //     },
      //   },
      //   required: true,
      // },
        // {
        //   label: '关账日期',
        //   field: 'jzdate',
        //   component: 'DatePicker',
        //   componentProps: {
        //     format: 'YYYY-MM-DD',
        //     // showTime: { format: 'HH:mm' },
        //     showTime: false,
        //     valueFormat: 'YYYY-MM-DD',
        //   },
        //   required: true,
        // },
      ],
    baseColProps: { lg: 24, md: 24 },
  });
  const [register, { closeModal, setModalProps }] = useModalInner(async (e) => {
    record.value = e;
    await resetFields();
    await setFieldsValue(e)
    
  });
  let title = ref<string>('修改商品数量');

  // 保存数据
  async function handleSubmit() {
    try {
      const data = await validate();
      setModalProps({ confirmLoading: true });
      // const res = await rdJzrqSave(data);
      // showMessage(res.message);
      setTimeout(closeModal);
      emit('success', data);
    } catch (error: any) {
      if (error && error.errorFields) {
        showMessage('您填写的信息有误，请根据提示修正。');
      }
      console.log('error', error);
    } finally {
      setModalProps({ confirmLoading: false });
    }
  }
 
</script>
<style scoped>
  .ant-picker {
    width: 80%;
  }
</style>
